// pages/edit/edit.js
Page({
    data: {
      img_url: [],
      content:'',
      title:'',
      detail:'',
      id:0
    },
    onLoad: function (options) {
      
    },
    input:function(e){
      this.setData({
        content:e.detail.value
      })
    },
    //发布按钮事件
    send:function(){
      var that = this;
      var user_id = wx.getStorageSync('userid')

      wx.request({
        url: 'http://1.15.55.133:8080/share/post',
        data:{
          sharecontent: this.data.detail,
          sharetitle: this.data.title,
          userid: this.data.id
        },
        header:{
          "Content-Type":"application/json"
        },
        method:'POST',
        success:function(res) {
          console.log("res", res);
          wx.navigateBack({
            delta: 1  //小程序关闭当前页面返回上一页面
          })
          wx.showToast({
            title: '发布成功',
            icon: 'success',
            duration: 2000
          })
        },
        fail:function(res){
          wx.showToast({
            title: '发布失败'
          })
        },
      })

/*
      wx.showLoading({
        title: '上传中',
        
      })*/
    },


  getTitle:function (e){
    console.log("title", e);
    console.log(e.detail.value);
    this.setData({
      title:e.detail.value
    })
  },
  getDe:function(e){
    console.log("detail",e);
    this.setData({
      detail:e.detail.value
    })
  }
})
